#include "menu.h"
#include"widget.h"

menu::menu(QWidget *parent)
    : QWidget{parent}
{
    this->setFixedSize(400,400);//窗口大小
    this->setWindowTitle("贪吃蛇");//窗口标题
    this->setWindowIcon(QIcon(":/ziyuan/C:/Users/Dell/Desktop/source/snake.png"));

    QPixmap pixmap=QPixmap(":/ziyuan/C:/Users/Dell/Desktop/source/bg.png");
    QPalette palette;
    palette.setBrush(QPalette::Window,QBrush (pixmap));
    this->setPalette(palette);

    //开始按钮
    this->startbt=new QPushButton(this);
    startbt->setIcon(QIcon(":/ziyuan/C:/Users/Dell/Desktop/source/begin.png"));
    startbt->setIconSize(QSize(304,89));
    this->startbt->setFlat(true);
    startbt->move(32,57);

    //结束按钮
    this->quitbt=new QPushButton(this);
    quitbt->setIcon(QIcon(":/ziyuan/C:/Users/Dell/Desktop/source/end.png"));
    quitbt->setIconSize(QSize(304,89));
    this->quitbt->setFlat(true);
    quitbt->move(32,226);

    connect(startbt,SIGNAL(clicked()),this,SLOT(opengame()));
    connect(quitbt,SIGNAL(clicked()),this,SLOT(closegame()));

    //QAbstractButton::connect(game->e->againbt,SIGNAL(click()),this,SLOT(opengame()));
}

menu::~menu()
{
    delete game;
}

void menu::opengame()
{
    this->hide();
    game->show();
}

void menu::closegame()
{
    this->hide();
}

